package org.restlet.example.jse.client;

import hu.diploma.common.resource.UserResource;
import hu.diploma.common.vos.DeviceVo;
import hu.diploma.common.vos.GroupVo;
import hu.diploma.common.vos.PersonVo;
import hu.diploma.common.vos.StructuredNameVo;
import hu.diploma.common.vos.UserVo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.restlet.resource.ClientResource;

public class Test {

	public static void main(String[] args) throws IOException {
		// ClientResource cr2 = new
		// ClientResource("http://127.0.0.1:8888/restlet/hello");

		// // Get the Contact object
		// BaseCampResourceIn resource2 = cr2.wrap(BaseCampResourceIn.class);
		//
		// System.out.println(resource2.hello());
		//
		ClientResource cr = new ClientResource("http://192.168.1.64:8080/web/restlet/user");

		// Get the Contact object
		UserResource resource = cr.wrap(UserResource.class);
		UserVo userVo = new UserVo();
		userVo.setName("Test");
		userVo.setPassword("1234");
		DeviceVo deviceVo = new DeviceVo();
		deviceVo.setModel("asdas");
		List<GroupVo> groupVos = new ArrayList<GroupVo>();
		GroupVo groupVo = new GroupVo();
		groupVo.setName("Group");
		List<PersonVo> people = new ArrayList<PersonVo>();
		PersonVo e = new PersonVo();
		StructuredNameVo structuredNameVo = new StructuredNameVo();
		structuredNameVo.setDisplayName("Name");
		e.setStructuredName(structuredNameVo);
		people.add(e);
		groupVo.setPeople(people);
		deviceVo.setGroups(groupVos);
		List<DeviceVo> devices = new ArrayList<DeviceVo>();
		devices.add(deviceVo);
		userVo.setDevices(devices);
		UserVo re = resource.create(userVo);
		System.out.println(re.toString());
		// System.out.println(resUserVo.getId() + " " + resUserVo.getName() +
		// " " + resUserVo.getPassword());
		// In case the Contact object is not available
		// Get a JSON representation of the contact
		// System.out.println("\nJSON representation");
		// cr.get(MediaType.APPLICATION_JSON).write(System.out);
	}
}
